package org.grayrabbit.cms.properties;

import java.util.HashMap;
import java.util.Map;

import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.module.propertyset.PropertySetManager;

public class PropertiesManager {
	private static PropertiesManager propertiesManager;
	private PropertySet propertySet;
	
	protected PropertiesManager(){
		loadPropertySet();
	}

	public static PropertiesManager getInstance(){
		if(propertiesManager==null){
			propertiesManager = new PropertiesManager();
		}
		return propertiesManager;
	}
	
	//刷新属性管理器
	public void refresh(){
		loadPropertySet();
	}
	
	public PropertySet getPropertySet(){
		return this.propertySet;
	}
	protected void loadPropertySet() {
		Map<String,Object> args = new HashMap<String,Object>();
		args.put("globalKey", "cms");
		PropertySet jdbcPs = PropertySetManager.getInstance("jdbc", args);
		
		Map<String,Object> args1 = new HashMap<String,Object>();
		args1.put("PropertySet", jdbcPs);
		args1.put("bulkload", Boolean.TRUE);
		this.propertySet = PropertySetManager.getInstance("cached", args1);
		
	}
}
